package com.dx.spring0_5.helloWorld;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

	public static void main(String[] args) {

		// 1. 创建 Spring 的 IOC 容器
		ApplicationContext ctx = new ClassPathXmlApplicationContext("com/dx/spring0_5/helloWorld/helloWorldApplicationContext.xml");
		
		// 2. 从 IOC 容器中获取 bean 的实例
		HelloWorld helloWorld = (HelloWorld) ctx.getBean("helloWorld");
		
		// 3. 调用hello方法
		helloWorld.printUserName();
		
		// 构造器注入
		Car car = (Car) ctx.getBean("car");
		System.out.println(car);
		
		Car car2 = (Car) ctx.getBean("car2");
		System.out.println(car2);
		
		Car car3 = (Car) ctx.getBean("car3");
		System.out.println(car3);
		
	}
}
